import {defineStore} from "pinia";
import {getHospitalDeparmentAPI, getHospitalDetailAPI} from "@/api/hospitalApi.ts";
import {ref} from "vue";

const useHospitalStore = defineStore('hospitalStore', () => {
    const hospitalDetail = ref<any>({})
    const hospitalDeparment = ref<any>([])
    const fetchHospitalDetail = async (hoscode: string) => {
        const {data} = await getHospitalDetailAPI(hoscode)
        hospitalDetail.value = data
        return data
    }

    const fetchHospitalDeparment = async (hoscode: string) => {
        const {data} = await getHospitalDeparmentAPI(hoscode)
        hospitalDeparment.value = data
    }

    return {
        hospitalDetail,
        hospitalDeparment,
        fetchHospitalDetail,
        fetchHospitalDeparment
    }
})

export default useHospitalStore
